#ifndef LOGDETAIL_H
#define LOGDETAIL_H

#include <QWidget>
#include "blldataflow.h"
#include "sqlhelper.h"
#include "datetimepicker.h"
#include "iexportable.h"

namespace Ui {
class LogDetail;
}

class IDataExport;
class LogDetail : public QWidget, public IExportable
{
    Q_OBJECT

public:
    explicit LogDetail(QWidget *parent = nullptr);
    ~LogDetail();

    void save(const QString &path);

private slots:
    void on_btnExport_clicked();
    void on_btnQuery_clicked();
    void on_btnDatetimeStart_clicked();
    void on_btnDatetimeEnd_clicked();

    void setWidgetVisibleSlot(int permission);
    void retranslateUiSlot();

    void changeDateTime(QDateTime dateTime, QString whatsThis);
    void setCurrentTimeSlot(int type);

    void pdfSaveDone(const QString &info, const QString &path);

private:
    void initWidget();
    void initTableHeader();
    QString generateTable(QStringList header, QList<LogInfo> info);
    void retranslateLogType();
    void resizeTableColumnWidth();
    void retranslateTable();

private:
    Ui::LogDetail *ui;
    BllDataFlow * bdf;
    SqlHelper * sqlHelper;
    DateTimePicker * dateTimePicker;
    QStringList tableHeader;
    QList<LogInfo> info;
    QString contentHtml;
    QString reportHtml;
    IDataExport *exportMgr;
};

#endif // LOGDETAIL_H
